import { h } from 'vue';
import { AdColumn } from '@/components/AdTable';
import { expandAndToString } from '@/utils/common';
import { BasicUpload } from '@/components/Upload';
import { TableImg } from '@/components/Table';
import { List } from '@/components/Linqts';
import { isArray, isNull, isObject, isString } from '@/utils/is';
import FileUpload from '/@/components/Form/src/components/FileUpload.vue';
import { debug } from 'console';
import { readNode } from './warehouseareapos.api';
import { AdInput } from '@/components/AdInput';
import { InputNumber, Input, Switch, DatePicker, TimePicker } from 'ant-design-vue';

export const columns: AdColumn[] = [
  {
    title: '主键',
    dataIndex: 'Id',
    dataType: 'guid',
    width: 300,
    defaultHidden: true,
    filterable: false,
    sorter: true,
    formVisible: true,
    formEditable: false,
  },
  {
    title: '库区名称',
    dataIndex: 'ParentName',
    dataType: 'string',
    width: 150,
    formVisible: false,
    formEditable: false,
    required: false,
    filterable: false,
    sorter: false,
  },
  {
    title: '库区',
    dataIndex: 'WareHouseAreaId',
    dataType: 'guid',
    width: 150,
    defaultHidden: true,
    formVisible: true,
    formEditable: true,
    required: true,
    filterable: true,
    sorter: true,
    editComponent: 'ApiSelect',
    editComponentProps: {
      api: readNode,
      // use name as label
      labelField: 'Name',
      // use id as value
      valueField: 'Id',
      immediate: true,
      optionFilterProp: 'label',
      showSearch: true,
    },
  },
  {
    title: '库位名称',
    dataIndex: 'AreaPosName',
    dataType: 'string',
    width: 150,
    formVisible: true,
    formEditable: true,
    required: false,
    filterable: true,
    sorter: true,
    formSchema:{
      // componentProps: ({ formModel,field })=>{
      //   formModel[field]=formModel['Group'];
      //   return {
      //     readonly:true,
      //     value: `${formModel['Group']}`
      //   }
      // },
      field:"AreaPosName",
      label:'库位名称',
      render:({ model, field })=>{
        return h(Input, {
          value: `${model['Channel'] ?? ''}-${model['Group'] ?? ''}-${model['LevelNo'] ?? ''}-${model['PosNo'] ?? ''}`,
          // onChange: (tags: string[]) => {
          //   model[field] = tags;
          // },
        });
      }
    }
  },
  {
    title: '通道',
    dataIndex: 'Channel',
    dataType: 'string',
    width: 150,
    formVisible: true,
    formEditable: true,
    required: false,
    filterable: false,
    sorter: false,
    formSchema:{
      componentProps: ({ formModel }) => {
        return {
          // onChange: (e: ChangeEvent) => {
          //   debugger
          //   if (e && e.target) {
          //     formModel.AreaPosName = e.target.value;
          //   }
          //   else {
          //     formModel.AreaPosName = e;
          //   }
          // },
        };
      },
    }
  },
  {
    title: '组',
    dataIndex: 'Group',
    dataType: 'string',
    width: 150,
    formVisible: true,
    formEditable: true,
    required: false,
    filterable: false,
    sorter: false,
  },
  {
    title: '层号',
    dataIndex: 'LevelNo',
    dataType: 'string',
    width: 150,
    formVisible: true,
    formEditable: true,
    required: false,
    filterable: false,
    sorter: false,
  },
  {
    title: '位号',
    dataIndex: 'PosNo',
    dataType: 'string',
    width: 150,
    formVisible: true,
    formEditable: true,
    required: false,
    filterable: false,
    sorter: false,
  },
];

export interface InputDto {}

export interface OutputDto {}
